<template>
  <div class="adv-wrapper">
    <div class="adv-wrapper-head">
      <div class="nav-title-row">
        <div class="label">
          {{title}}
          <span class="new font-color-red">{{subTitle}}</span>
        </div>
        <a href="javascript:void;" @click="onMore" class="more">
          {{moreText}}
          <van-icon name="arrow"/>
        </a>
      </div>
    </div>
    <div :class="'adv-wrapper-body body-'+type">
      <a
        @click="clickItem(item)"
        class="item"
        v-for="(item,index) in list"
        :key="index"
      >
        <div class="pictrue adv-pic">
          <img :src="item.image" class="image">
        </div>
        <div v-show="type=='card'" class="item-card-desc">
          <div class="name line1">{{item.storeName}}</div>
          <div class="money font-color-red">
              ￥
              <span class="num">{{item.price}}</span>
          </div>
        </div>
        <div v-show="type=='list'" class="adv-desc">
          <div class="text">
            <div class="line1">{{item.storeName}}</div>
            <div class="money font-color-red">
              ￥
              <span class="num">{{item.price}}</span>
            </div>
            <div class="vip-money">
              <div class="vip">￥{{item.vipPrice}}</div>
              <span class="num">已售{{item.sales}}</span>
            </div>
          </div>
        </div>
        <van-icon
          v-show="type=='list'"
          name="cart-circle-o"
          @click="addCart(item,$event)"
          class="adv-icon-cart cart-color"
        ></van-icon>
      </a>
    </div>
  </div>
</template>

<script>
export default {
  name: "ProductList",
  props: {
    type: {
      type: String,
      default: 'list',
    },
    title: {
      type: String,
      default: ""
    },
    subTitle: {
      type: String,
      default: ""
    },
    moreText: {
      type: String,
      default: "更多"
    },
    onMore: {
      type: Function,
      default: function() {}
    },
    list: {
      type: Array,
    }
  },
  methods: {
    clickItem(item) {
      console.log("item", item);
      this.$router.push({path:"details",query:item})
    },
    addCart(id, ev) {
      ev.cancelBubble = true;
      console.log("id", id);
    }
  }
};
</script>

<style lang="less">
@color: #f2f2f2;
@txt-color1: #333;

.font-color-red {
  color: #00c17b !important;
}

.nav-menu {
  padding-top: 0.26rem;
  display: flex;
  flex-wrap: wrap;
  .nav-menu-item {
    width: 25%;
    text-align: center;
    font-size: 0.26rem;
    .pic,
    .txt {
      width: 100%;
      text-align: center;
    }
    .pic {
      height: 1.5rem;
      font-size: 58px;
      color: rgb(79, 192, 141);
      margin: 0 auto 12px auto;
      i {
        border-radius: 50%;
        background: gainsboro;
      }
      img {
        width: 1.5rem;
        height: 1.5rem;
      }
    }
    .txt {
      height: 25px;
      color: @txt-color1;
    }
  }
}
.vip-money {
  display: flex;
  .vip {
    margin-right: 0.22rem;
    text-decoration: line-through;
  }
  .num {
    font-size: 0.22rem;
    color: #aaa;
    font-weight: 400;
    margin: -0.02rem 0 0 0;
  }
}

.nav-title-row {
  height: 1.15rem;
  align-items: center;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #eee;
  padding-top: 0.3rem;
  margin: 0 0.3rem;
  label,
  .label {
    font-size: 0.55rem;
    font-weight: 700;
    margin-right: 0.2rem;
    width: 50%;
  }
  a {
    float: right;
    font-size: .5rem;
    color: #fff;
    width: 40%;
    text-align: right;
  }
}
.adv-wrapper {
  .adv-wrapper-head {
    .text {
      font-size: 0.3rem;
      color: #999;
      width: 5.3rem;
      text-align: left;
    }
    .more {
      font-size: 0.4rem;
      color: #333;
    }
  }
  .adv-wrapper-body {
    &.body-list{
       .item {
         display: flex;
       }
    }
    &.body-card{
      display: flex;
        .item{
          width: 3rem;
          display: block;
          float: left;
        }
      
    }
    .item {
      position: relative;
      padding-left: 0.3rem;
      padding-bottom: 0.1rem;
      background-color: #fff;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      color: #333;
      border-bottom: 1px solid #f7f7f7;
    }
    .adv-pic,
    img {
      width: 2.5rem;
      height: 2.5rem;
      position: relative;
    }
    .adv-desc {
      font-size: 0.4rem;
      color: #222;
      width: 6.7rem;
      text-align: left;
      padding: 0.3rem 0.3rem 0.3rem 0;
      // border-bottom: 1px solid #f5f5f5;
      .text {
        line-height: 0.7rem;
      }
    }
    .adv-icon-cart {
      position: absolute;
      right: 0.5rem;
      width: 0.5rem;
      height: 0.5rem;
      border-radius: 50%;
      bottom: 1.2rem;
      bottom: 0.8rem;
      color: #00c17b;
      // border: 1px solid #00c17b!important;
      font-size: 0.8rem;
    }
  }
}
 .name.line1 {
  font-size: 0.3rem;
  color: #282828;
  margin-top: 0.12rem;
}
.font-color-red {
  color: #73cbb6 !important;
}
.money {
  font-size: 15px;
  font-weight: 700;
  margin-top: 4px;
}
</style>
